<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<script>


function searchSupplier(){
	
	
	var supplierName = $("#supplierName").val();
	var indicator = $("#indicator").val();

        $('#dataGridSupplier').datagrid({
    		url : 'headQSupplierMgmtJSONAction!selectSupplierVosByPage',
    		
    	    queryParams: {
    	    	'formBean.indicator':indicator,
    	    	'formBean.order.supplier.name':supplierName,
    	    },
    		fit : true,
    		fitColumns : true,
    		pagination : true,
    		pageSize : 15,
    		pageList : [ 15, 20],
    		border : false,
    		checkOnSelect : false,
    		selectOnCheck : false,
    		sortName : 'receiveAmtSum',
    		sortOrder : 'desc',
    		singleSelect:true,
    		showFooter:true,
    		rownumbers:true,
    		nowrap : false,
    		columns : [[
    					{field:'name', width:200,title:'供应商名字',fixed:true,
							formatter: function (value, row, index){
							return row.name;
						}},
						{field:'tags', width:200,title:'标签',fixed:true,
							formatter: function (value, row, index){
								return row.tags;
							}},
						{field:'pinyin', width:100,title:'拼音',fixed:true,
							formatter: function (value, row, index){
								return row.pinyin;
							}},
						{field:'comment', width:400,title:'备注',fixed:true,
							formatter: function (value, row, index){
							return row.comment;
						}},
						{field:'currentAcctBalance', width:100,title:'当前账目',fixed:true,
							formatter: function (value, row, index){
							return row.currentAcctBalance;
						}},
						 {				
							field : 'action',
							title : '选择',
							width : 70,
						formatter : function(value, row, index) {
							var str = '';
							str += $.formatString('<a href="#" onclick="selectSupplier(\'{0}\',\'{1}\',\'{2}\');"><img border="0" src="{3}" title="供应商信息"/></a>', row.id,row.name,row.currentAcctBalance,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/select.png');
							return str;
						}},
    			     ]],

    	});
        
        $("#SupplierDiv").dialog("open");
}

function selectSupplier(supplierId, supplierName,currentAcctBalance){
	$("#supplierId").val(supplierId);
	$("#supplierName").textbox("setValue",supplierName);
	$("#currentAcctBalance").textbox("setValue",currentAcctBalance);
	$("#SupplierDiv").dialog("close");
	changeSelectBySupplierInput(supplierId);
}
function clearSupplier(){
	$("#supplierId").val(0);
	$("#supplierName").textbox("setValue","");
	$("#currentAcctBalance").textbox("setValue","");
	changeSelectByCustInputClear();
}

</script>

<s:form id="supplierForm" name="supplierForm" action="" theme="simple" method="POST">
<s:hidden id="supplierId" name="formBean.order.supplier.id" />

	<table  border="0" cellpadding="0" cellspacing="0"  class="InnerTableContent">
		<tr>
			<td width="20%" align="left"><strong>供应商：</strong></td>
			<td width="170"><s:textfield cssClass="easyui-searchbox" id="supplierName" data-options="prompt:'请输入供应商',searcher:searchSupplier"
					name="formBean.order.supplier.name" size="25" />					
			</td>
						
			<td >
				<a href="#" class="easyui-linkbutton"
				data-options="iconCls:'icon-no'" onclick="clearSupplier();"
				style="width: 60px">清除</a></td>
							
			<td width="80"></td>
		</tr>
		<tr>	
			<td  align="left"><strong>欠款金额：</strong></td>
			<td ><s:textfield cssClass="easyui-textbox"
					name="formBean.order.supplier.currentAcctBalance"
					id="currentAcctBalance" size="25" data-options="editable:false,prompt:'供应商当前欠款'"/>
			</td>
			<td></td>
			<td></td>
		</tr>
		</table>

</s:form>

<div id="SupplierDiv" class="easyui-dialog"
	style="width: 1150px; height: 510px"
	data-options="title:'查找供应商',modal:false,closed:true,resizable:true">
	
	<table id="dataGridSupplier" border="0">
	</table>
</div>